
/*
* PURPOSE: Democracy Reduces Health Inequalities: Evidence Using Individual-level Data on Infant Mortality in Africa, 1960-2016 - Replication Tables and Figures
* Data Source: master_data_Demo_Inequal.dta and SSA_country_Vdem.dta
* AUTHORs: Carmen Jacqueline Ho, Marie Christelle Mabeu, and Roland Pongou
DATE: 2025 March
*/

*---------------------------------------------------------------------------*
*				 			SET YOUR DIRECTORY 	
*--------------------------------------------------------------------------*	
*Set your directory here 
global Demo_Inequality "C:\Users\Marie Christelle\Dropbox\Democracy and Inequality\Submission_JOP\Replication"
global Demo_Inequality_figures "C:\Users\Marie Christelle\Dropbox\Apps\Overleaf\Ho_Mabeu_Pongou_Democracy and inequality_JOP\Figures"
global Demo_Inequality_tables "C:\Users\Marie Christelle\Dropbox\Apps\Overleaf\Ho_Mabeu_Pongou_Democracy and inequality_JOP\Tables"

clear all 
set maxvar 32767

*---------------------------------------------------------------------------*
*				 			FIGURE 1
*--------------------------------------------------------------------------*

cd "${Demo_Inequality}/"
use "SSA_country_Vdem.dta", clear


foreach y of varlist  Tetanus  { 
preserve
bys country : egen mean_demo_country=mean(Vdem_EDI)
bys country : egen mean_`y'_country=mean(`y')
bys country: gen count2=_n
drop if count2>1
twoway (scatter mean_`y'_country mean_demo_country , mlabel(iso3) mlabsize(tiny) ) || lfit mean_`y'_country mean_demo_country, title("Panel A: Maternal immunization", size(medium)) legend(off) xtitle(VDEM Electoral Democracy Index) ytitle(Percentage) ylab(, nogrid) xlab(, nogrid) aspectratio(0.9) graphregion(color(white)) 
graph save `y'.gph,replace
restore

}


foreach y of varlist  prenatal { 
preserve
bys country : egen mean_demo_country=mean(Vdem_EDI)
bys country : egen mean_`y'_country=mean(`y')
bys country: gen count2=_n
drop if count2>1
twoway (scatter mean_`y'_country mean_demo_country , mlabel(iso3) mlabsize(tiny) ) || lfit mean_`y'_country mean_demo_country, title("Panel B: Prenatal care", size(medium)) legend(off) xtitle(VDEM Electoral Democracy Index) ytitle(Percentage) ylab(, nogrid) xlab(, nogrid) aspectratio(0.9) graphregion(color(white)) 
graph save `y'.gph,replace
restore

}


foreach y of varlist  Skilledbirth  { 
preserve
bys country : egen mean_demo_country=mean(Vdem_EDI)
bys country : egen mean_`y'_country=mean(`y')
bys country: gen count2=_n
drop if count2>1
twoway (scatter mean_`y'_country mean_demo_country , mlabel(iso3) mlabsize(tiny) ) || lfit mean_`y'_country mean_demo_country, title("Panel C: Skilled birth", size(medium)) legend(off) xtitle(VDEM Electoral Democracy Index) ytitle(Percentage) ylab(, nogrid) xlab(, nogrid) aspectratio(0.9) graphregion(color(white)) 
graph save `y'.gph,replace
restore

}


foreach y of varlist   water  { 
preserve
bys country : egen mean_demo_country=mean(Vdem_EDI)
bys country : egen mean_`y'_country=mean(`y')
bys country: gen count2=_n
drop if count2>1
twoway (scatter mean_`y'_country mean_demo_country , mlabel(iso3) mlabsize(tiny) ) || lfit mean_`y'_country mean_demo_country, title("Panel D: Access to improved" "water sources", size(medium)) legend(off) xtitle(VDEM Electoral Democracy Index) ytitle(Percentage) ylab(, nogrid) xlab(, nogrid) aspectratio(0.9) graphregion(color(white)) 
graph save `y'.gph,replace
restore

}


foreach y of varlist   sanitation { 
preserve
bys country : egen mean_demo_country=mean(Vdem_EDI)
bys country : egen mean_`y'_country=mean(`y')
bys country: gen count2=_n
drop if count2>1
twoway (scatter mean_`y'_country mean_demo_country , mlabel(iso3) mlabsize(tiny) ) || lfit mean_`y'_country mean_demo_country, title("Panel E: Access to improved" "sanitation facilities", size(medium)) legend(off) xtitle(VDEM Electoral Democracy Index) ytitle(Percentage) ylab(, nogrid) xlab(, nogrid) aspectratio(0.9) graphregion(color(white)) 
graph save `y'.gph,replace
restore

}

cd "${Demo_Inequality}/"
graph combine Tetanus.gph prenatal.gph Skilledbirth.gph   water.gph sanitation.gph ,  ysize(1) xsize(2) ycommon   graphregion(color(white))  col(3) 
cd "${Demo_Inequality_figures}/"
graph export Figure1.png, as(png) replace



*---------------------------------------------------------------------------*
*				 			FIGURE 3
*--------------------------------------------------------------------------*


*************************************Event-Study - 2years bandwidth ********************************************
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

*** 3. Create the year of democratization for each country that move from autocracy to democracy*****
gen myear = .
label variable myear "Year of autocracy to democracy"

** 3.1 BENIN ***
replace myear = 1992 if country=="Benin"

** 3.2 BENIN ***
replace myear = 1967 if country=="Botswana"

** 3.3 Burkina Faso **
replace myear = 1999 if country=="Burkina Faso"

** 3.4 Ghana **
replace myear = 1995 if country=="Ghana"

** 3.5 Lesotho**
replace myear = 2002 if country=="Lesotho"

** 3.6 Liberia **
replace myear = 2006 if country=="Liberia"

** 3.7 Madagascar**
replace myear = 1994 if country=="Madagascar"

** 3.8 Malawi**
replace myear = 2009 if country=="Malawi"

** 3.9 Mali**
replace myear = 1993 if country=="Mali"

** 3.10 Namibia**
replace myear = 1995 if country=="Namibia"

** 3.11 Niger**
replace myear = 2011 if country=="Niger"

** 3.12 Nigeria**
replace myear = 2012 if country=="Nigeria"

** 3.13 Senegal **
replace myear = 1984 if country=="Senegal"

** 3.14 Sierra Leone **
replace myear = 2003 if country=="Sierra Leone"

** 3.15 South Africa **
replace myear = 1995 if country=="South Africa"

** 3.16 Tanzania**
replace myear = 1996 if country=="Tanzania"

** 3.17 Zambia**
replace myear = 2002 if country=="Zambia"


rename year_birth_child year

** 4.1 Indicator for democratized countries with only one transition to democracy (1) With both a transition to democracy and a reversal to autocracy (2) with only a reversal to autocracy (3) no transition (0) **
gen democ = country=="Benin" |country=="Botswana" |country=="Burkina Faso"|country=="Lesotho"|country=="Liberia" |country=="Nigeria" | country=="Senegal" |country=="Sierra Leone" |country=="South Africa"   

replace democ=2 if country=="Ghana"|country=="Madagascar" |country=="Malawi" |country=="Mali"|country=="Namibia" |country=="Niger" |country=="Tanzania" |country=="Zambia"  

*** 4.2 Create democracy dummies  ***
gen treat = year>myear & democ==1

*** 4.3 Create year-wise dummies for how many years have passed since democratization ***
gen byte treat1 = year == myear + 1 & democ >0
replace treat1 = 1 if year == myear + 2 & democ >0

gen byte treat2 = year == myear + 3 & democ >0
replace treat2 = 1 if year == myear + 4 & democ >0

gen byte treat3 = year == myear + 5 & democ >0
replace treat3 = 1 if year == myear + 6 & democ >0

gen byte treat4 = year == myear + 7 & democ >0
replace treat4 = 1 if year == myear + 8 & democ >0

gen byte treat5 = year == myear + 9  & democ >0
replace treat5 = 1 if year == myear + 10 & democ >0

gen byte treat6 = year >= myear + 11  & democ >0

gen byte pre0 = year == myear & democ >0

gen byte pre1 = year == myear - 1  & democ >0
replace pre1 = 1 if year == myear - 2 & democ>0

gen byte pre2 = year == myear - 3  & democ >0
replace pre2 = 1 if year == myear - 4 & democ >0

gen byte pre3 = year == myear - 5  & democ >0
replace pre3 = 1 if year == myear - 6 & democ >0

gen byte pre4 = year == myear - 7  & democ >0
replace pre4 = 1 if year == myear - 8 & democ >0

gen byte pre5 = year == myear - 9  & democ >0
replace pre5 = 1 if year == myear - 10 & democ >0

gen byte pre6 = year >= myear - 11  & democ >0

/* Label main regressors */
label variable pre6 "11+ years before"
label variable pre5 "9-10 years before"
label variable pre4 "7-8 years before"
label variable pre3 "5-6 years before"
label variable pre2 "3-4 years before"
label variable pre1 "1-2 years before"
label variable pre0 "Year of democratization"
label variable treat1 "1-2 years after"
label variable treat2 "3-4 years after"
label variable treat3 "5-6 years after"
label variable treat4 "7-8 years after"
label variable treat5 "9-10 years after"
label variable treat6 "11+ years after"


preserve
/********************************************************************************
	All countries Estimation including children born the year before democratization + one year bandwidth 
**********************************************************************************/
/* Clear the estimation results stored in the memory */
set more off
eststo clear

global yearFE i.year_survey i.year 
global childlist bdum* i.dmale 
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

/********* Estimation *********/
xtset motherid
eststo: xtreg IM i.pre6##i.twin i.pre5##i.twin i.pre4##i.twin i.pre3##i.twin i.pre2##i.twin i.pre0##i.twin i.treat1##i.twin i.treat2##i.twin i.treat3##i.twin i.treat4##i.twin i.treat5##i.twin i.treat6##i.twin $yearFE cohort_country_* cohort_region_* $childlist, fe cluster(dhsyear_cluster)
/* Store Control variable indicators */
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 

/*********Then storing the estimates*********/
estimates store pre_post11_1

/*********Create a Stata data file in which the estimated democracy coefficients are stored*********/
cd "${Demo_Inequality}/"

/* Point estimates and 95 confidence intervals for making a graph */
local output1 Figure3.dta
local output2 Figure3_Table.tex
local output3 Figure3.gph
local output4 Figure3.png

/* Delete the Stata data file with the same name as the one to be created, if it exists */
cap erase `output1'
/* Create a blank Stata data file with variables 
		yr: # of years since the year of democratization 
		beta: Point estimates
		ci_l95: Lower bound of the 95 percent confidence interval
		ci_u95: Upper bound of the 95 percent confidence interval 
		*/
qui postfile bskeep yr beta ci_l95 ci_u95 using `output1', replace
/* Fill each cell for years before democratization */
foreach num of numlist 6 5 4 3 2 0 { 
	local cil95 = _b[1.pre`num'#1.twin] - _se[1.pre`num'#1.twin]*invttail(25, 0.025)
	local ciu95 = _b[1.pre`num'#1.twin] + _se[1.pre`num'#1.twin]*invttail(25, 0.025)
	post bskeep (-`num') (_b[1.pre`num'#1.twin]) (`cil95') (`ciu95')
	}
	
	/* Fill each cell for reference year */
foreach num of numlist 1 { 
	post bskeep (-`num') (0) (0) (0)
	}

/* Fill each cell for years after democratization */
foreach num of numlist 1 2 3 4 5 6 {
	local cil95 = _b[1.treat`num'#1.twin] - _se[1.treat`num'#1.twin]*invttail(25, 0.025)
	local ciu95 = _b[1.treat`num'#1.twin] + _se[1.treat`num'#1.twin]*invttail(25, 0.025)
	post bskeep (`num') (_b[1.treat`num'#1.twin]) (`cil95') (`ciu95')
	}
/* Save the Stata data file */
qui postclose bskeep



/*********Finally plotting the event study graph *********/
cd "${Demo_Inequality}/"

/* Point estimates and 95 confidence intervals for making a graph */
local output1 Figure3.dta
local output2 Figure3_Table.tex
local output3 Figure3.gph
local output4 Figure3.png

use `output1', clear
sort yr 
replace yr=-11 if yr==-6
replace yr=-10 if yr==-5
replace yr=-8 if yr==-4
replace yr=-6 if yr==-3
replace yr=-4 if yr==-2
replace yr=-2 if yr==-1
replace yr=11 if yr==6
replace yr=10 if yr==5
replace yr=8 if yr==4
replace yr=6 if yr==3
replace yr=4 if yr==2
replace yr=2 if yr==1


twoway (scatter beta yr, connect(l) lwidth(medthick) lcolor(navy) mcolor(navy) msize(medium) msymbol(circle))  (rcap ci_u ci_l yr, lwidth(medium) lcolor(navy) mcolor(navy) msize(medium)),	  xline(-0.5, lcolor(cranberry) lwidth(medthick) lpattern(longdash)) xlabel(-11 -10 -8 -6 -4 -2 0 2 4 6 8 10 11, labsize(small))  	xtitle("Time to democratization (years)")  ytitle("Effect on twin-singleton difference in infant mortality")  yline(0, lcolor(gs10) lwidth(medthin))  legend(off)  graphregion(fcolor(white))
cd "${Demo_Inequality}/"
graph save `output3', replace
cd "${Demo_Inequality_figures}/"
graph export `output4', as(png) replace





*---------------------------------------------------------------------------*
*				 			Table 1. CHARACTERISTICS OF MOTHER AND NFANTS IN TRANSITIONED COUNTRIES
*--------------------------------------------------------------------------*
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

edit country motherid year_birth_child transition_all country_with_transition 

**Keep only transitioning countries
drop if country_with_transition==.

**Flag for birth before and after the transition 
codebook transition_all
bys motherid: egen max_transition=max(transition_all) 
bys motherid: egen min_transition=min(transition_all) 
gen birth_before_after=.
replace birth_before_after=1 if max_transition!=min_transition 

**Flag for birth only before or only after the transition
gen birth_before=.
replace birth_before=1 if birth_before_after==.  & max_transition==0 

gen birth_after=.
replace birth_after=1 if birth_before_after==.  & max_transition==1 

drop max_transition min_transition

**Number of mother who gave birth both before and after transition
bys motherid birth_before_after: gen temp=_n
gen temp2=temp 
replace temp2=. if birth_before_after==.
replace temp2=. if temp>1 
egen total_mother_before_after=total(temp2)
tab temp2,m 
drop temp temp2 

**Number of mother who gave birth only before or after transition
bys motherid birth_before: gen temp=_n
gen temp2=temp 
replace temp2=. if birth_before==.
replace temp2=. if temp>1 
egen total_mother_before=total(temp2)
tab temp2,m 
drop temp temp2 

bys motherid birth_after: gen temp=_n
gen temp2=temp 
replace temp2=. if birth_after==.
replace temp2=. if temp>1 
egen total_mother_after=total(temp2)
tab temp2,m 
drop temp temp2 

***Verify sum to total mother 
gen total_mother=total_mother_before_after + total_mother_before + total_mother_after
codebook motherid 


**Total Number of live birth from mother who gave birth both before and after transition 
egen total_birth_before_after= total(birth_before_after)
tab birth_before_after,m

** Total number of live birth before transition for the sample of mother who gave birth before and after transition 
gen temp=birth_before_after
replace temp=. if transition_all==1
egen live_birth_both_before= total(temp)
drop temp

** Total number of live birth after transition for the sample of mother who gave birth before and after transition 
gen temp=birth_before_after
replace temp=. if transition_all==0
egen live_birth_both_after= total(temp)
drop temp

** Total number of live birth for the sample of mother who gave birth only before transition
egen live_birth_before=total(birth_before)
tab birth_before,m

** Total number of live birth for the sample of mother who gave birth only after transition 
egen live_birth_after=total(birth_after)
tab birth_after,m


*****Number of children by twin status
edit country motherid year_birth_child transition_all country_with_transition dmale twin

**Total number of births (both before and after transition)
bys motherid: gen birth_total=_N 

**Total number births (both before and after transition): twin 
bys motherid: egen birth_total_twin=total(twin)
replace birth_total_twin=birth_total_twin/2
tab birth_total_twin,m

**Total number births (both before and after transition): singleton 
gen dsingleton=(twin==0)
replace dsingleton=. if twin==.
bys motherid: egen birth_total_singleton=total(dsingleton)  
drop dsingleton 

**Total number of birth before or after transition 
gen temp=(transition_all==0)
replace temp=. if transition_all==.
bys motherid: egen birth_total_before=total(temp)

bys motherid: egen birth_total_after=total(transition_all) 
drop temp 

**Total number of birth before or after transition: twin 
gen twin_transition= twin*transition_all 
replace twin_transition=. if twin==0
gen temp=(twin_transition==0)
replace temp=. if twin_transition==.
bys motherid: egen birth_total_before_twin=total(temp)
tab birth_total_before_twin,m
replace birth_total_before_twin=birth_total_before_twin/2
tab birth_total_before_twin,m

bys motherid: egen birth_total_after_twin=total(twin_transition)
tab birth_total_after_twin,m
replace birth_total_after_twin=birth_total_after_twin/2
tab birth_total_after_twin,m

drop temp twin_transition 

**Total number of birth before or after transition: singleton 
gen dsingleton=(twin==0)
gen dsingleton_transition= dsingleton*transition_all 
replace dsingleton_transition=. if dsingleton==0
gen temp=(dsingleton_transition==0)
replace temp=. if dsingleton_transition==.
bys motherid: egen birth_total_before_singleton=total(temp)

bys motherid: egen birth_total_after_singleton=total(dsingleton_transition)

drop temp dsingleton_transition

***Flag for twin and singleton both before and after transition
gen twin_singleton_before_after=1 if birth_total_before_twin>0 & birth_total_before_singleton>0 & birth_total_after_twin>0 & birth_total_after_singleton>0

***Flag for twin and singleton  only before transition 
gen twin_singleton_before=1 if twin_singleton_before_after==. & birth_total_before_twin>0 & birth_total_before_singleton>0

***Flag for twin and singleton  only after transition 
gen twin_singleton_after=1 if twin_singleton_before_after==. & birth_total_after_twin>0 & birth_total_after_singleton>0


**Number of mother who gave birth to twin and singleton children both before and after transition
bys motherid twin_singleton_before_after: gen temp=_n
gen temp2=temp 
replace temp2=. if twin_singleton_before_after==.
replace temp2=. if temp>1 
egen mother_twin_singl_before_after=total(temp2)
tab temp2,m 
drop temp temp2 

**Number of mother who gave birth to twin and singleton children only before or after transition
bys motherid twin_singleton_before: gen temp=_n
gen temp2=temp 
replace temp2=. if twin_singleton_before==.
replace temp2=. if temp>1 
egen mother_twin_singleton_before=total(temp2)
tab temp2,m 
drop temp temp2 

bys motherid twin_singleton_after: gen temp=_n
gen temp2=temp 
replace temp2=. if twin_singleton_after==.
replace temp2=. if temp>1 
egen mother_twin_singleton_after=total(temp2)
tab temp2,m 
drop temp temp2 


**Total number of twin singleton birth both before and after transition
egen twin_singleton_birth_total=total(twin_singleton_before_after)
tab twin_singleton_before_after,m

**Total number of twin and singleton birth before transition among the sample of women who gave birth to both sex both before and after transition
gen temp=twin_singleton_before_after
replace temp=. if transition_all==1
egen twin_singl_birth_total_before=total(temp)
drop temp 

**Total number of twin and singleton birth after transition among the sample of women who gave birth to both sex both before and after transition
gen temp=twin_singleton_before_after
replace temp=. if transition_all==0
egen twin_singleton_birth_total_after=total(temp)
drop temp 

**Total number of twin and singleton birth only before transition
egen twin_singleton_birth_before=total(twin_singleton_before)
tab twin_singleton_before,m

**Total number of twin and singleton birth only after transition
egen twin_singleton_birth_after=total(twin_singleton_after)
tab twin_singleton_after,m

gen temp=twin_singleton_birth_total+twin_singleton_birth_before+twin_singleton_birth_after
drop temp 

**collapse to Mother level data 
bys motherid: gen count=_n
drop if count>1

edit total_mother total_mother_before_after total_mother_before total_mother_after birth_total birth_total_twin birth_total_singleton birth_total_before birth_total_after birth_total_before_twin birth_total_after_twin birth_total_before_singleton birth_total_after_singleton mother_twin_singl_before_after mother_twin_singleton_before mother_twin_singleton_after twin_singleton_birth_total twin_singl_birth_total_before twin_singleton_birth_total_after twin_singleton_birth_before twin_singleton_birth_after

*edit child_birth_total_twin child_birth_total_singleton child_birth_total_before child_birth_total_after child_birth_total_before_twin child_birth_total_after_twin child_birth_total_before_singleton child_birth_total_after_singleton

***Descriptive stat for Table 1: 
sum mother_twin_singl_before_after mother_twin_singleton_before  mother_twin_singleton_after twin_singl_birth_total_before twin_singleton_birth_total_after  twin_singleton_birth_before twin_singleton_birth_after

sum total_mother_before_after total_mother_before total_mother_after live_birth_both_before live_birth_both_after  live_birth_before live_birth_after

/*
****Note for Table 1: Mothers and infants. We copy-paste the mean value from the summary statistics tables above 
Panel A: Mothers who gave birth to twins OR singletons
Number of mothers who gave birth Both before and after democratization = total_mother_before_after
Number of mothers who gave birth only before democratization = total_mother_before
Number of mothers who gave birth only after democratization = total_mother_after
Number of live births from mothers who gave birth Both before and after democratization = live_birth_both_before + live_birth_both_after
Number of live births from mothers who gave birth only before democratization = live_birth_before 
Number of live births from mothers who gave birth only after democratization = live_birth_after 

Panel B: Mothers who gave birth to twins AND singletons
Number of mothers who gave birth Both before and after democratization = mother_twin_singl_before_after
Number of mothers who gave birth only before democratization = mother_twin_singleton_before
Number of mothers who gave birth only after democratization = mother_twin_singleton_after
Number of live births from mothers who gave birth Both before and after democratization = twin_singl_birth_total_before + twin_singleton_birth_total_after
Number of live births from mothers who gave birth only before democratization = twin_singleton_birth_before 
Number of live births from mothers who gave birth only after democratization = twin_singleton_birth_after 
*/

 
*---------------------------------------------------------------------------*
*				 			Table 2. Democracy and the gap in twin-singleton mortality 
*--------------------------------------------------------------------------*

************************************* Panel A - V-dem Dichotomous measure ********************************************
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale 
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

 quietly foreach x of varlist Vdem_EDI_dummy {

 foreach var of varlist IM  {

 
***column 1 ******
set more off
xtset countrycode
eststo column1_`var': xtreg `var' i.twin##i.`x' $yearFE, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 
estadd local trend2 

***column 2 ******
set more off
xtset countrycode
eststo column2_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe  
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2  

***column 3 ******
set more off
xtset countrycode
eststo column3_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 4 ******
set more off
xtset countrycode
eststo column4_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe  
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 5 ******
set more off
xtset motherid
eststo column5_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe  
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

}
}

cd "${Demo_Inequality_tables}/"
esttab column1_IM column2_IM column3_IM column4_IM column5_IM  using Table_2.tex, keep(1.twin 1.Vdem_EDI_dummy 1.twin#1.Vdem_EDI_dummy) replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment label nobaselevels nomtitles title (Democracy and the Gap in Twin-Singleton Mortality - Difference-in-Differences Estimates) ///
varlabels( , elist(1.twin \addlinespace  1.Vdem_EDI_dummy \addlinespace  1.twin#1.Vdem_EDI_dummy \addlinespace) ) ///
collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\textbf{Dependent variable: Risk of infant death (per thousand)}}  \\ ///
\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel A: V-Dem Electoral Democracy Index, Dichotomous Measure}}} \\) prefoot(\addlinespace) postfoot(\addlinespace) /// 
stat(N N_clust, fmt(%11.0gc %11.0gc ) layout(@ @ ) ///
labels("Observations" "Number of DHS cluster" ))


************************************* Panel B - V-dem continuous measure ********************************************

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale 
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

label var Vdem_EDI "Democracy"

 quietly foreach x of varlist Vdem_EDI {

 foreach var of varlist IM  {

 
***column 1 ******
set more off
xtset countrycode
eststo column1_`var': xtreg `var' i.twin##c.`x' $yearFE, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe "\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1 
estadd local trend1 
estadd local trend2 

***column 2 ******
set more off
xtset countrycode
eststo column2_`var': xtreg `var' i.twin##c.`x' $yearFE cohort_country_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe "\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 

***column 3 ******
set more off
xtset countrycode
eststo column3_`var': xtreg `var' i.twin##c.`x' $yearFE cohort_country_* cohort_region_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe "\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1 
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 4 ******
set more off
xtset countrycode
eststo column4_`var': xtreg `var' i.twin##c.`x' $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe "\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe  
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 5 ******
set more off
xtset motherid
eststo column5_`var': xtreg `var' i.twin##c.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
}
}


cd "${Demo_Inequality_tables}/"
esttab column1_IM column2_IM column3_IM column4_IM column5_IM  using Table_2.tex, keep(1.twin Vdem_EDI 1.twin#c.Vdem_EDI) append /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment label nobaselevels nomtitles  ///
varlabels( , elist(1.twin \addlinespace  Vdem_EDI \addlinespace  1.twin#c.Vdem_EDI \addlinespace) ) ///
nonumber nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel B: V-Dem Electoral Democracy Index, Continuous Measure}}} \\) prefoot(\addlinespace) ///
stat(N N_clust ysfe ybfe cfe trend1 trend2 cov1 mfe  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" "Mother FE" ))






*---------------------------------------------------------------------------*
*				 			Table 3. Democracy and the Gap in Twin-Singleton Mortality - Robustness to Income and Foreign Aid Controls
*--------------------------------------------------------------------------*

************************************* V-dem Dichotomous measure ********************************************

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp
global householdlist i.wealth_pca_index

 quietly foreach x of varlist Vdem_EDI_dummy {

 foreach var of varlist IM  {

 
***column 1 ******
set more off
xtset motherid
eststo column1_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist lngdppc2015, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 2 ******
set more off
xtset motherid
eststo column2_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist lngdppc2015 lag_lngdppc2015, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

***column 3 ******
set more off
xtset motherid
eststo column3_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist ODA_gdp, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

***column 4 ******
set more off
xtset motherid
eststo column4_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist $householdlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

***column 5 ******
set more off
xtset motherid
eststo column5_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist $householdlist $countrylist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

}
}

cd "${Demo_Inequality_tables}/"

esttab column1_IM column2_IM column4_IM column3_IM  column5_IM using Table_3.tex, keep(1.twin 1.Vdem_EDI_dummy 1.twin#1.Vdem_EDI_dummy) replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (Democracy and the Gap in Twin-Singleton Mortality - Robustness to Income and Foreign Aid ) ///
mtitles("\shortstack{(1)\\Log GDP}" "\shortstack{(2)\\Log GDP + lag of log GDP}"  "\shortstack{(3)\\Household wealth}" "\shortstack{(4)\\ODA}" "\shortstack{(5)\\All controls}") ///
varlabels( , elist(1.twin \addlinespace  1.Vdem_EDI_dummy \addlinespace  1.twin#1.Vdem_EDI_dummy \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\textbf{Dependent variable: Risk of infant death (per thousand)}} \\ ///
\addlinespace \multicolumn{6}{c}{\emph{\textbf{V-Dem Electoral Democracy Index, Dichotomous Measure}}} \\) prefoot(\addlinespace)  /// 
stat(N N_clust ysfe ybfe trend1 trend2 cov1 mfe  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" "Mother FE" ))



********************************************************************************************************
****************            Table 4- Democracy and the Gap in Infant Mortality Across Various Groups -Difference-in-Differences Estimates
               ***************************************
****************                              ***************************************
********************************************************************************************************

************************************* Panel A - V_dem EDI dichotomous measure ********************************************

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

**Rural dummy
gen rural=.
replace rural=0 if urban_rural==1 //Urban
replace rural=1 if urban_rural==0 //Rural
label define rural  1 "Group", replace
label values rural rural  

****Marital dummy
*drop married
gen notmarried=1
replace notmarried=0 if marital==1
replace notmarried=. if marital==.
label var notmarried "Mother is not married"

label define notmarried  1 "Group", replace
label values notmarried notmarried  

**Poor dummy
gen poor=0
replace poor=1 if wealth_pca_index==1 //Poorest
replace poor=. if wealth_pca_index==. 

label define poor  1 "Group", replace
label values poor poor  

**No education 
label define noeduc  1 "Group", replace
label values noeduc noeduc  



set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp


 quietly foreach x of varlist Vdem_EDI_dummy {

 foreach var of varlist IM  {

 foreach z of varlist notmarried rural noeduc poor {
 
  gen group=`z'

***column 1 ******
set more off
xtset countrycode
eststo col1_`var'_`z': xtreg `var' i.group##i.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local cov1 "\checkmark" 
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

drop group 

}

}
}

cd "${Demo_Inequality_tables}/"

esttab col1_IM_poor col1_IM_notmarried col1_IM_noeduc col1_IM_rural  using Table_4.tex, keep(1.group 1.Vdem_EDI_dummy 1.group#1.Vdem_EDI_dummy) replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (Democracy and the Gap in Infant Mortality Across Various Groups - Difference-in-Differences Estimates ) ///
mtitles("\shortstack{(1)\\Poor/Rich}" "\shortstack{(2)\\Unmarried/Married}" "\shortstack{(3)\\Uneducated/Educated}" "\shortstack{(4)\\Rural/Urban}" ) ///
varlabels( , elist(1.group \addlinespace  1.Vdem_EDI_dummy \addlinespace  1.group#1.Vdem_EDI_dummy \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{5}{c}{\textbf{Dependent variable: Risk of infant death (per thousand)}} \\ ///
\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel A: V-Dem Electoral Democracy Index, Dichotomous Measure}}} \\)  /// 
prefoot(\addlinespace) postfoot(\addlinespace) /// 
stat(N N_clust, fmt(%11.0gc %11.0gc ) layout(@ @ ) ///
labels("Observations" "Number of DHS cluster" ))


************************************* Panel B - V_dem EDI Continuous measure ********************************************

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

**Rural dummy
gen rural=.
replace rural=0 if urban_rural==1 //Urban
replace rural=1 if urban_rural==0 //Rural
label define rural  1 "Group", replace
label values rural rural  

****Marital dummy
*drop married
gen notmarried=1
replace notmarried=0 if marital==1
replace notmarried=. if marital==.
label var notmarried "Mother is not married"

label define notmarried  1 "Group", replace
label values notmarried notmarried  

**Poor dummy
gen poor=0
replace poor=1 if wealth_pca_index==1 //Poorest
replace poor=. if wealth_pca_index==. 

label define poor  1 "Group", replace
label values poor poor  

**No education 
label define noeduc  1 "Group", replace
label values noeduc noeduc  



set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

label var Vdem_EDI "Democracy"

 quietly foreach x of varlist Vdem_EDI {

 foreach var of varlist IM  {

 foreach z of varlist notmarried rural noeduc poor {
 
  gen group=`z'

***column 1 ******
set more off
xtset countrycode
eststo col1_`var'_`z': xtreg `var' i.group##c.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local cov1 "\checkmark" 
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

drop group 

}

}
}

cd "${Demo_Inequality_tables}/"

esttab col1_IM_poor col1_IM_notmarried col1_IM_noeduc col1_IM_rural  using Table_4.tex, keep(1.group Vdem_EDI 1.group#c.Vdem_EDI) append /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment label nobaselevels nomtitles  ///
varlabels( , elist(1.group \addlinespace  Vdem_EDI \addlinespace  1.group#c.Vdem_EDI \addlinespace) ) ///
nonumber nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\addlinespace \multicolumn{5}{c}{\emph{\textbf{Panel B: V-Dem Electoral Democracy Index, Continuous Measure}}} \\) prefoot(\addlinespace) ///
stat(N N_clust ysfe ybfe cfe trend1 trend2 cov1  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" ))





*---------------------------------------------------------------------------*
*				 			Table 5. Unbundling Democracy 
*--------------------------------------------------------------------------*

************************************* Panel A - V_dem EDI dichotomous measure ********************************************

***********What type of political change matter? ( clean_el_dummy  elecoff_dummy  suffr_dummy  frassoc_thick_dummy  freexp_altinf_dummy)******
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

rename suffr_dummy A
rename clean_el_dummy B
rename elecoff_dummy C
rename frassoc_thick_dummy D
rename freexp_altinf_dummy E

*****Mother FE
eststo clear
local clear

foreach y of varlist A B C D E {

label define dem 0 "Autocracy" 1 "Component of Democracy", replace
rename `y' dem
label values dem dem 
label variable dem "Component of Democracy"

set more off
xtset motherid

eststo column_`y': xtreg IM i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

rename dem `y' 

		}

cd "${Demo_Inequality_tables}/"

esttab column_A column_B column_C  column_D column_E  using Table_5.tex, ///
keep(1.twin 1.dem 1.twin#1.dem) replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs nonumbers fragment label nobaselevels title (Unbundling Democracy and Investigating Dual Track Capture) ///
mtitles("\shortstack{Suffrage\\(1)}" "\shortstack{Elections\\(2)}" "\shortstack{Elected officials\\(3)}" "\shortstack{Freedom of  association\\(4)}" "\shortstack{Freedom of expression\\(5)}") ///
mgroups("Electoral democracies" "Liberal Democracies", pattern(1 0 0 1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr)  {@span})) ///
varlabels( , elist(1.twin \addlinespace 1.dem \addlinespace 1.twin#1.dem \addlinespace)) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\emph{\textbf{Dependent variable: Risk of infant death (per thousand)}}} \\ ///
\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel A: Components of V-Dem Electoral Democracy Index, Dichotomous Measure}}} \\) prefoot(\addlinespace) /// 
stat(N N_clust, fmt(%11.0gc %11.0gc ) layout(@ @ ) ///
labels("Observations" "Number of DHS cluster" ))
 


************************************* Panel B - V_dem EDI Continuous measure********************************************

***********What type of political change matter? ( clean_el  elecoff  suffr  frassoc_thick  freexp_altinf )******
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

rename suffr A
rename clean_el B
rename elecoff C
rename frassoc_thick D
rename freexp_altinf E

*****Mother FE
eststo clear
local clear

foreach y of varlist A B C D E {
rename `y' dem
label values dem dem 
label variable dem "Component of Democracy"

set more off
xtset motherid

eststo column_`y': xtreg IM i.twin##c.dem $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

rename dem `y' 

		}


cd "${Demo_Inequality_tables}/"

esttab column_A column_B column_C  column_D column_E  using Table_5.tex, ///
keep(1.twin dem 1.twin#c.dem) append /// 
cells(b(star fmt(2)) se( par fmt(3))) noobs booktabs fragment label nobaselevels nomtitles  ///
varlabels( , elist(1.twin \addlinespace dem \addlinespace 1.twin#c.dem \addlinespace)) ///
nonumber nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel B: Components of V-Dem Electoral Democracy Index, Continuous Measure}}} \\) prefoot(\addlinespace) ///
stat(N N_clust ysfe ybfe trend1 trend2 cov1 mfe  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country-specific trend" "Region-specific trend" "Child Characteristics" "Mother FE" ))



*---------------------------------------------------------------------------*
*				 			Table 6. Distribution of Basic Goods Between Twins and Singletons After Democratization 
*--------------------------------------------------------------------------*


************************************* Vdem - Dichotomous measure of democracy ********************************************
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

rename water_index_dum water
rename sanitation_index_dum sanitation

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

 quietly foreach x of varlist Vdem_EDI_dummy {

 foreach var of varlist  tetanus ante_visit skilledbirth water sanitation  {

 
***column 4 ******
set more off
xtset countrycode
eststo column4_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_*  $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

}
}


cd "${Demo_Inequality_tables}/"

esttab column4_tetanus column4_ante_visit column4_skilledbirth column4_water column4_sanitation using Table_6.tex, keep(1.twin 1.Vdem_EDI_dummy 1.twin#1.Vdem_EDI_dummy) replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (Distribution of Basic Goods and Services Between Twins and Singletons After Democratization ) ///
mtitles("\shortstack{(1)\\Maternal immunization}" "\shortstack{(2)\\Prenatal care}" "\shortstack{(3)\\Skilled birth attendance}" "\shortstack{(4)\\Access to improved water}" "\shortstack{(5)\\Access to improved sanitation}") ///
varlabels( , elist(1.twin \addlinespace  1.Vdem_EDI_dummy \addlinespace  1.twin#1.Vdem_EDI_dummy \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\textbf{V-Dem Electoral Democracy Index, Dichotomous Measure}} \\) ///
prefoot(\addlinespace)  /// 
stat(N N_clust ysfe ybfe cfe trend1 trend2 cov1, fmt(%11.0gc %11.0gc 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" ))


rename  water water_index_dum
rename  sanitation sanitation_index_dum



*---------------------------------------------------------------------------*
*				 			Table 7. The Effect of Basic Goods on the Gap in Twin-Singleton Mortality
*--------------------------------------------------------------------------*

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

rename water_index_dum water
rename sanitation_index_dum sanitation

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp


*****Country FE
eststo clear
local clear

foreach y of varlist  tetanus ante_visit skilledbirth water sanitation {
gen  health_input=`y'
label define health_input 0 "No intervention" 1 "Intervention", replace
label values health_input health_input  

set more off
xtset countrycode

eststo column1_`y': xtreg IM i.twin##i.health_input $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


sum health_input
estadd scalar mean=r(mean)
estadd scalar sd=r(sd)
drop health_input 

		}

cd "${Demo_Inequality_tables}/"

esttab column1_tetanus column1_ante_visit column1_skilledbirth column1_water column1_sanitation  using Table_7.tex, ///
keep(1.twin 1.health_input 1.twin#1.health_input )  replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (The Effect of Basic Goods on the Gap in Twin-Singleton Mortality) ///
mtitles("\shortstack{(1)\\Maternal immunization}" "\shortstack{(2)\\Prenatal care}" "\shortstack{(3)\\Skilled birth attendance}" "\shortstack{(4)\\Access to improved water}" "\shortstack{(5)\\Access to improved sanitation}") ///
varlabels( , elist(1.twin \addlinespace  1.health_input \addlinespace  1.twin#1.health_input \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\textbf{Dependent Variable: Risk of Infant Death (per thousand)}} \\) ///
prefoot(\addlinespace)  /// 
stat(N N_clust ysfe ybfe cfe trend1 trend2 cov1, fmt(%11.0gc %11.0gc 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" ))

rename  water water_index_dum
rename  sanitation sanitation_index_dum








********************************************************************************************************
****************            APPENDIX TABLES                ***************************************
****************                              ***************************************
********************************************************************************************************


*---------------------------------------------------------------------------*
*				 			Appendix Table A1. The Effect of Democracy on the Distribution of Twins and Singletons
*--------------------------------------------------------------------------*

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

 quietly foreach x of varlist Vdem_EDI_dummy {

 foreach var of varlist twin  {

 
***column 1 ******
set more off
xtset countrycode
eststo column1_`var': xtreg `var' i.`x' $yearFE, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 
estadd local trend2 

***column 2 ******
set more off
xtset countrycode
eststo column2_`var': xtreg `var' i.`x' $yearFE cohort_country_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 

***column 3 ******
set more off
xtset countrycode
eststo column3_`var': xtreg `var' i.`x' $yearFE cohort_country_* cohort_region_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 4 ******
set more off
xtset countrycode
eststo column4_`var': xtreg `var' i.`x' $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 5 ******
set more off
xtset motherid
eststo column5_`var': xtreg `var' i.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

}
}

cd "${Demo_Inequality_tables}/"

esttab column1_twin column2_twin column3_twin column4_twin column5_twin  using Table_A1.tex, keep(1.Vdem_EDI_dummy) replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (The Effect of Democracy on the Distribution of Twins and Singletons ) ///
mtitles("\shortstack{(1)}" "\shortstack{(2)}" "\shortstack{(3)}" "\shortstack{(4)}" "\shortstack{(5)}") ///
varlabels( , elist( 1.Vdem_EDI_dummy \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\textbf{Dependent variable: Probability of being a twin}} \\ ) ///
prefoot(\addlinespace)  /// 
stat(N N_clust ysfe ybfe cfe trend1 trend2 cov1 mfe  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" "Mother FE" ))



*---------------------------------------------------------------------------*
*				 			Appendix Table A2. DESCRIPTIVE STATISTICS
*--------------------------------------------------------------------------*
clear all 
cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

cd "${Demo_Inequality_tables}/"

gen IM_twin=IM 
replace IM_twin=. if twin==0
gen IM_singleton=IM 
replace IM_singleton=. if twin==1

label var IM "IM All children"
label var IM_twin "IM Twin"
label var IM_singleton "IM Singleton"
label var dmale "Child is a boy"
label var twin "Child is a twin"
label var bord "Birth order number"
label var year_birth_child "Year birth of child"
label var age_mom_atbirth "Age mother at delivery"
label var child_id "Number of children"
label var motherid "Number of mothers"
label var country "Number of countries"

*****Child level characteristics
foreach y of varlist  IM_twin  {
estpost tabstat `y' , statistics(n mean sd min max) columns(statistics)
matrix n=e(count)
matrix mean=e(mean)
matrix sd=e(sd)
matrix min=e(min)
matrix max=e(max)
esttab . using "Table_A2.tex", nostar noobs nonote  booktabs fragment label nobaselevels /// 
cells("count (fmt(%11.0gc)) mean (fmt(2)) sd (fmt(2)) min (fmt(0)) max (fmt(0))" ) nomtitle ///
collabels("N" "Mean" "Std. de." "Min." "Max.") ///
replace
}

foreach y of varlist  IM_singleton IM dmale twin bord year_birth_child  {
estpost tabstat `y' , statistics(n mean sd min max) columns(statistics)
matrix n=e(count)
matrix mean=e(mean)
matrix sd=e(sd)
matrix min=e(min)
matrix max=e(max)
esttab . using "Table_A2.tex", nostar noobs nonote  booktabs fragment label nobaselevels nonumber nolines collabels(none) /// 
cells("count (fmt(%11.0gc)) mean (fmt(2)) sd (fmt(2)) min (fmt(0)) max (fmt(0))" ) nomtitle ///
append
}

*****Mother level characteristics
preserve
bys motherid: gen nb_child1=_N
bys motherid: gen temp=_n
drop if temp>1
label var year_birth_mother "Year birth of mother"
label var nb_child1 "Number of children"
label var married "Mother is married"
label var noeduc "Mother has no education"
label var urban_rural "Urban residence"

foreach y of varlist  year_birth_mother nb_child1 married noeduc urban_rural  {
estpost tabstat `y' , statistics(n mean sd min max) columns(statistics)
matrix n=e(count)
matrix mean=e(mean)
matrix sd=e(sd)
matrix min=e(min)
matrix max=e(max)
esttab . using "Table_A2.tex", nostar noobs nonote  booktabs fragment label nobaselevels nonumber nolines collabels(none) /// 
cells("count (fmt(%11.0gc)) mean (fmt(2)) sd (fmt(2)) min (fmt(0)) max (fmt(0))" ) nomtitle ///
append
}
restore

*****country-level characteristics
preserve
bys country: egen IM_country=mean(IM)

bys country: gen nb_child2=_N
bys country year_birth_child: gen temp=_n
drop if temp>1
bys country: egen avgGDP2015=mean(gdppc2015)
bys country: egen avgODA_gdp=mean(ODA_gdp)
bys country: egen avgVdem_EDI=mean(Vdem_EDI)
bys country: egen avgVdem_EDI_dummy=mean(Vdem_EDI_dummy)
bys country : gen temp2=_n
drop if temp2>1

label var nb_child2 "Number of children per country"
label var avgVdem_EDI "V-Dem's Electoral Democracy Index (continuous)"
label var avgVdem_EDI_dummy "V-Dem's Electoral Democracy Index (dummy)"
label var avgGDP2015 "GDP per capita (in 2015 US)"
label var avgODA_gdp "ODA as a percentage of GDP"

foreach y of varlist  nb_child2 avgVdem_EDI_dummy avgGDP2015 avgODA_gdp  {
estpost tabstat `y' , statistics(n mean sd min max) columns(statistics)
matrix n=e(count)
matrix mean=e(mean)
matrix sd=e(sd)
matrix min=e(min)
matrix max=e(max)
esttab . using "Table_A2.tex", nostar noobs nonote  booktabs fragment label nobaselevels nonumber nolines collabels(none) /// 
cells("count (fmt(%11.0gc)) mean (fmt(2)) sd (fmt(2)) min (fmt(0)) max (fmt(0))" ) nomtitle ///
append
}
restore


*---------------------------------------------------------------------------*
*				 			Appendix Table A4. The Effect of Democracy on Health Inequality, Alternative Cutoffs (0.6 and 0.42)
*--------------------------------------------------------------------------*

************************************* Panel A - V-dem>0.6  ********************************************

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp


 quietly foreach x of varlist Vdem_EDI_dummy2 {

 foreach var of varlist IM  {

 
***column 1 ******
set more off
xtset countrycode
eststo column1_`var': xtreg `var' i.twin##i.`x' $yearFE, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 
estadd local trend2 

***column 2 ******
set more off
xtset countrycode
eststo column2_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 

***column 3 ******
set more off
xtset countrycode
eststo column3_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 4 ******
set more off
xtset countrycode
eststo column4_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 5 ******
set more off
xtset motherid
eststo column5_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

}
}

cd "${Demo_Inequality_tables}/"

esttab column1_IM column2_IM column3_IM column4_IM column5_IM  using Table_A4.tex, keep(1.twin 1.Vdem_EDI_dummy2 1.twin#1.Vdem_EDI_dummy2)  replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (The Effect of Democracy on Health Inequality, Alternative Cutoffs (0.6 and 0.42) ) ///
mtitles("\shortstack{(1)}" "\shortstack{(2)}" "\shortstack{(3)}" "\shortstack{(4)}" "\shortstack{(5)}") ///
varlabels( , elist(1.twin \addlinespace  1.Vdem_EDI_dummy2 \addlinespace  1.twin#1.Vdem_EDI_dummy2 \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{6}{c}{\textbf{Dependent variable: Risk of infant death (per thousand)}} \\ ///
\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel A: V-Dem Electoral Democracy Index is above 0.6}}} \\) /// 
prefoot(\addlinespace) postfoot(\addlinespace) /// 
stat(N N_clust, fmt(%11.0gc %11.0gc ) layout(@ @ ) ///
labels("Observations" "Number of DHS cluster" ))


************************************* Panel B - V-dem>0.42  ********************************************

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

*Dummy Variable 3
gen Vdem_EDI_dummy3=.
replace Vdem_EDI_dummy3=0 if v2x_polyarchy<=0.42
replace Vdem_EDI_dummy3=1 if v2x_polyarchy>0.42  & v2x_polyarchy!=. 
label define Vdem_EDI_dummy3 0 "Autocracy" 1 "Democracy" , replace
label values Vdem_EDI_dummy3 Vdem_EDI_dummy3
label variable Vdem_EDI_dummy3 "Electoral democracy index by V-dem - Dummy 0.42"
tab Vdem_EDI_dummy3,m


set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp


 quietly foreach x of varlist Vdem_EDI_dummy3 {

 foreach var of varlist IM  {

 
***column 1 ******
set more off
xtset countrycode
eststo column1_`var': xtreg `var' i.twin##i.`x' $yearFE, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 
estadd local trend2 

***column 2 ******
set more off
xtset countrycode
eststo column2_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 

***column 3 ******
set more off
xtset countrycode
eststo column3_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_*, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 4 ******
set more off
xtset countrycode
eststo column4_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe "\checkmark"
estadd local mfe 
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"


***column 5 ******
set more off
xtset motherid
eststo column5_`var': xtreg `var' i.twin##i.`x' $yearFE cohort_country_* cohort_region_* $childlist, fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"

}
}

cd "${Demo_Inequality_tables}/"

esttab column1_IM column2_IM column3_IM column4_IM column5_IM  using Table_A4.tex, keep(1.twin 1.Vdem_EDI_dummy3 1.twin#1.Vdem_EDI_dummy3) append /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment label nobaselevels nomtitles  ///
varlabels( , elist(1.twin \addlinespace  1.Vdem_EDI_dummy3 \addlinespace  1.twin#1.Vdem_EDI_dummy3 \addlinespace) ) ///
nonumber nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\addlinespace \multicolumn{6}{c}{\emph{\textbf{Panel B: V-Dem Electoral Democracy Index is above 0.42}}} \\) prefoot(\addlinespace) ///
stat(N N_clust ysfe ybfe cfe trend1 trend2 cov1 mfe  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE" "Country FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" "Mother FE" ))



*---------------------------------------------------------------------------*
*				 			Appendix Table A5. The Effect of Democracy on Health Inequality, Alternative Measures
*--------------------------------------------------------------------------*

cd "${Demo_Inequality}/"
use "master_data_Demo_Inequal.dta", clear

set more off
eststo clear
local clear

global yearFE i.year_survey i.year_birth_child 
global childlist bdum* i.dmale  
global countrylist lngdppc2015 lag_lngdppc2015 ODA_gdp

label define dem 0 "Autocracy" 1 "Democracy", replace

*****Mother FE
 quietly foreach var of varlist IM  {
label define dem 0 "Autocracy" 1 "Democracy", replace

 ***column 1 ******
rename Vdem_ROW dem
label values dem dem 
label variable dem "Democracy measure"

set more off
xtset motherid
eststo column1_`var': xtreg `var' i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 
rename dem Vdem_ROW 


 ***column 2 ******
rename POL2 dem
label values dem dem 
label variable dem "Democracy measure"

set more off
xtset motherid
eststo column2_`var': xtreg `var' i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 
rename dem POL2 


 ***column 3 ******
set more off
xtset motherid
eststo column3_`var': xtreg `var' i.twin##c.demPRS $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe "\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 


 ***column 4 ******
rename FH dem
label values dem dem 
label variable dem "Democracy measure"

set more off
xtset motherid
eststo column4_`var': xtreg `var' i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 
rename dem FH 

 ***column 5 ******
rename demPS2_boderline dem
label values dem dem 
label variable dem "Democracy measure"

set more off
xtset motherid
eststo column5_`var': xtreg `var' i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 
rename dem demPS2_boderline 


 ***column 6 ******
rename demBMR2 dem
label values dem dem 
label variable dem "Democracy measure"

set more off
xtset motherid
eststo column6_`var': xtreg `var' i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 
rename dem demBMR2 


 ***column 7 ******
rename demANRR dem
label values dem dem 
label variable dem "Democracy measure"

set more off
xtset motherid
eststo column7_`var': xtreg `var' i.twin##i.dem $yearFE cohort_country_* cohort_region_* $childlist , fe robust cluster(dhsyear_cluster) nonest
estadd local ysfe"\checkmark"
estadd local ybfe "\checkmark"
estadd local cfe 
estadd local mfe  "\checkmark"
estadd local cov1  "\checkmark"
estadd local trend1 "\checkmark"
estadd local trend2 "\checkmark"
estadd local trend3 
rename dem demANRR 

}

cd "${Demo_Inequality_tables}/"

esttab column1_IM column2_IM column3_IM column4_IM column5_IM column6_IM column7_IM  using Table_A5.tex, keep(1.twin demPRS 1.dem 1.twin#c.demPRS 1.twin#1.dem)  replace /// 
cells(b(star fmt(2)) se( par fmt(3)))  noobs booktabs fragment nonumbers label nobaselevels title (The Effect of Democracy on Health Inequality, Alternative Measures ) ///
mtitles("\shortstack{(1)\\V-dem ROW}" "\shortstack{(2)\\Polity IV}" "\shortstack{(3)\\PRS}" "\shortstack{(4)\\FH}" "\shortstack{(5)\\PS}" "\shortstack{(6)\\BMR}" "\shortstack{(7)\\ANRR}")  ///
varlabels( , elist(1.twin \addlinespace  1.dem \addlinespace  1.twin#1.dem \addlinespace) ) ///
nolines collabels(none)  star(* 0.1 ** 0.05 *** 0.01) ///
posthead(\midrule \multicolumn{8}{c}{\textbf{Dependent variable: Risk of infant death (per thousand)}} \\ ///
) prefoot(\addlinespace) /// 
stat(N N_clust ysfe ybfe trend1 trend2 cov1 mfe  , fmt(%11.0gc %11.0gc 0 0 0 0 0 0) layout(@ @ @ @ @ @ @ @) ///
labels("Observations" "Number of DHS cluster" "\midrule Survey year FE" "Year of birth FE"  "Country-specific trend" "Region-specific trend" "Child Characteristics" "Mother FE" )) ///








